<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>欢迎使用校园二手交易系统</title>

    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <!-- Custom fonts for this template-->
    <link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
    <link
            href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i"
            rel="stylesheet">

    <!-- Custom styles for this template-->
    <link href="css/sb-admin-2.min.css" rel="stylesheet">

    <link href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <!-- 引入detail样式 -->
    <link rel="stylesheet" href="css/detail.css">
    <link rel="stylesheet" href="css/collection.css">
</head>
<script type="text/javascript" src="../js/jquery.min.js" ></script>

<body onload="init()">
<script src="https://cdn.bootcss.com/echarts/4.4.0-rc.1/echarts-en.common.min.js"></script>
<div id="wrapper">

    <!-- Sidebar -->
    <ul class="navbar-nav bg-gradient-primary sidebar sidebar-dark accordion" id="accordionSidebar">

        <a class="sidebar-brand d-flex align-items-center justify-content-center" href="main.html">
            <div class="sidebar-brand-icon rotate-n-15">
                <i class="fas fa-laptop-house"></i>
            </div>
            <div class="sidebar-brand-text mx-3" style="font-size: 19px;">校园二手交易</div>
        </a>

        <hr class="sidebar-divider">

        <!-- 商品相关 -->
        <div class="sidebar-heading" style="font-size: 16px;">
            商品相关
        </div>

        <!-- 商品信息 -->
        <li class="nav-item">
            <a class="nav-link" href="goodsList.html">
                <i class="fas fa-fw fa-newspaper"></i>
                <span style="font-size: 20px;">商品信息</span>
            </a>
        </li>

        <!-- 发帖子 -->
        <li class="nav-item">
            <a class="nav-link" href="goodsPost.html">
                <i class="fas fa-fw fa-edit"></i>
                <span style="font-size: 20px;">发布商品</span>
            </a>
        </li>

        <!-- 我发布的 -->
        <li class="nav-item">
            <a class="nav-link" href="goodsPersonal.html">
                <i class="fas fa-fw fa-envelope"></i>
                <span style="font-size: 20px;">我发布的</span></a>
        </li>

        <!-- 我的收藏 -->
        <li class="nav-item">
            <a class="nav-link" href="collectPage.html">
                <i class="fas fa-fw fa-star"></i>
                <span style="font-size: 20px;">我的收藏</span></a>
        </li>

        <!-- 我的订单 -->
        <li class="nav-item">
            <a class="nav-link" href="orderList.html">
                <i class="fas fa-fw fa-clipboard-list"></i>
                <span style="font-size: 20px;">我的订单</span></a>
        </li>

        <!-- 对我的出价 -->
        <li class="nav-item">
            <a class="nav-link" href="bidList.html">
                <i class="fas fa-fw fa-hands-helping"></i>
                <span style="font-size: 20px;">对我的出价</span></a>
        </li>

        <!-- 我的出价 -->
        <li class="nav-item">
            <a class="nav-link" href="bidListMyself.html">
                <i class="fas fa-fw fa-hand-sparkles"></i>
                <span style="font-size: 20px;">我的出价</span></a>
        </li>

        <hr class="sidebar-divider">

        <!-- 个人相关 -->
        <div class="sidebar-heading" style="font-size: 16px;">
            个人相关
        </div>

        <!-- 个人资料 -->
        <li class="nav-item">
            <a class="nav-link" href="userInfo.html">
                <i class="fas fa-fw fa-user"></i>
                <span style="font-size: 20px;">个人资料</span></a>
        </li>

        <!-- 我的消息 -->
        <li class="nav-item">
            <a class="nav-link" href="talk.html">
                <i class="fas fa-fw fa-comments"></i>
                <span style="font-size: 20px;">我的消息</span></a>
        </li>

        <!-- 对我的评价 -->
        <li class="nav-item">
            <a class="nav-link" href="userEvaluationMyself.html">
                <i class="fas fa-fw fa-comment"></i>
                <span style="font-size: 20px;">对我的评价</span></a>
        </li>

        <!-- 我的评价 -->
        <li class="nav-item active">
            <a class="nav-link" href="userEvaluationMyselfPost.html">
                <i class="fas fa-fw fa-pen"></i>
                <span style="font-size: 24px; font-weight: bold">我的评价</span></a>
        </li>

        <!-- Divider -->
        <hr class="sidebar-divider d-none d-md-block">

        <!-- Sidebar Toggler (Sidebar) -->
        <div class="text-center d-none d-md-inline">
            <button class="rounded-circle border-0" id="sidebarToggle"></button>
        </div>

    </ul>
    <!-- End of Sidebar -->

    <!-- Content Wrapper -->
    <div id="content-wrapper" class="d-flex flex-column">

        <!-- Main Content -->
        <div id="content">

            <nav class="navbar navbar-expand navbar-light bg-white topbar mb-4 static-top shadow">
                <div style="margin-left: 15px">
                    以下是其他用户对您的评价
                </div>
                <button id="sidebarToggleTop" class="btn btn-link d-md-none rounded-circle mr-3">
                    <i class="fa fa-bars"></i>
                </button>

                <!-- Topbar Navbar -->
                <ul class="navbar-nav ml-auto">

                    <li class="nav-item dropdown no-arrow">
                        <a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button"
                           data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                <span class="mr-2 d-none d-lg-inline text-gray-600 small">
                                        欢迎您，
                                        <input type="text" id="wecomeName" style="width: 80px; border-style: none" disabled>
                                </span>
                            <img class="img-profile rounded-circle" id="sculpture"
                                 src="img/undraw_profile.svg">
                        </a>
                        <!-- Dropdown - User Information -->
                        <div class="dropdown-menu dropdown-menu-right shadow animated--grow-in"
                             aria-labelledby="userDropdown">

                            <a class="dropdown-item" href="#" data-toggle="modal" data-target="#logoutModal">
                                <i class="fas fa-sign-out-alt fa-sm fa-fw mr-2 text-gray-400"></i>
                                退出登录
                            </a>
                        </div>
                    </li>

                </ul>

            </nav>
            <!-- 详情页内容部分start -->
            <div style="margin-left: 20px">
                头像:&ensp;&ensp;&ensp;&ensp;&ensp;<img id="photoShow" alt="头像" width="200" height="200" style="border-radius:50%!important"/><br>
                <br>
                用户名:&ensp;&ensp;&ensp;<a id="userName"></a></br>
                <br>
                城市:&ensp;&ensp;&ensp;&ensp;&ensp;<a id="cityName"></a></br>
                <br>
                学校:&ensp;&ensp;&ensp;&ensp;&ensp;<a id="schoolName"></a></br>
                <br>
                学号:&ensp;&ensp;&ensp;&ensp;&ensp;<a id="studentId"></a></br>

            </div>
            </br>
            <div id="main" style="width: 500px;height:300px;margin: auto;"></div>

            <div class="product_detail clearfix w">
                <div class="detail fr" id="mod">
                </div>
            </div>
            </br>
            </br>
            <div class="copyright text-center my-auto">
                <button class="btn-secondary" onclick="prePage()">上一页</button>
                <input type="hidden" id="prePage"/>
                <input type="text" value="1" id="pageNum" style="width: 30px; border-style: none;text-align:center" disabled/>
                <button class="btn-secondary" onclick="nextPage()">下一页</button>
                <input type="hidden" id="nextPage"/>
            </div>
        </div>
    </div>
</div>
<!--        底部-->
<footer class="sticky-footer bg-white">
    <div class="container my-auto">
        <div class="copyright text-center my-auto">
            <span>致 力 于 打 造 最 方 便 安 全 的 校 园 二 手 交 易 服 务</span>
        </div>
    </div>
</footer>

<!-- Logout Modal-->
<div class="modal fade" id="logoutModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
     aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalLabel">确定要退出登录？</h5>
                <button class="close" type="button" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">×</span>
                </button>
            </div>
            <div class="modal-body">点击‘退出’后，退出系统...</div>
            <div class="modal-footer">
                <button class="btn btn-secondary" type="button" data-dismiss="modal">取消</button>
                <a class="btn btn-primary" href="login.html">退出</a>
            </div>
        </div>
    </div>
</div>

<!-- Bootstrap core JavaScript-->
<script src="vendor/jquery/jquery.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

<!-- Core plugin JavaScript-->
<script src="vendor/jquery-easing/jquery.easing.min.js"></script>

<!-- Custom scripts for all pages-->
<script src="js/sb-admin-2.min.js"></script>

<!-- Page level plugins -->
<script src="vendor/chart.js/Chart.min.js"></script>

<!-- Page level custom scripts -->
<script src="js/demo/chart-area-demo.js"></script>
<script src="js/demo/chart-pie-demo.js"></script>


</body>
<script>
    userInfo = JSON.parse(sessionStorage.getItem('userInfo'));
    if(userInfo.userName != null){
        document.getElementById('wecomeName').value = userInfo.userName; // 设置用户名
    }
    $("#sculpture").attr("src", userInfo.photo);  // 设置头像
    userId = userInfo.userId;

    function init() {
        $.ajax({ // 获取用户信息
            type : "GET",
            url : "user/user-server/getUser",
            headers: { // token
                'Authorization' : userInfo.token
            },
            dataType : "json",        //返回数据形式为json
            data: {"id": userId},
            success : function(result) {
                if (result.status == 200) {
                    var data = result.data;
                    document.getElementById('userName').innerHTML = data.userName;
                    document.getElementById('studentId').innerHTML = data.studentId;
                    $("#photoShow").attr("src",data.photo);
                    $.ajax({ // 获取城市名称
                        type : "GET",
                        async: true,
                        url : "user/user-server/getCity",
                        headers: { // token
                            'Authorization' : userInfo.token
                        },
                        dataType : "json",        //返回数据形式为json
                        data: {"id": data.cityId},
                        success : function(result) {
                            if (result.status == 200) {
                                var city = result.data;
                                document.getElementById('cityName').innerHTML = city.cityName;
                            }
                            else{
                                alert(result.msg);
                            }
                        }
                    })
                    $.ajax({ // 获取学校名称
                        type : "GET",
                        async: true,
                        url : "user/user-server/getSchool",
                        headers: { // token
                            'Authorization' : userInfo.token
                        },
                        dataType : "json",        //返回数据形式为json
                        data: {"id": data.schoolId},
                        success : function(result) {
                            if (result.status == 200) {
                                var school = result.data;
                                document.getElementById('schoolName').innerHTML = school.schoolName;
                            }
                            else{
                                alert(result.msg);
                            }
                        }
                    })
                }
                else{
                    alert(result.msg);
                }
            }
        })
        $.ajax({
            type: "GET",
            async: false,
            url: "evaluation/evaluation-server/numPost",
            headers: { // token
                'Authorization': userInfo.token
            },
            dataType: "json",        //返回数据形式为json
            data: {"userId": userId},
            success: function (result) {
                if (result.status == 200) {
                    var myChart = echarts.init(document.getElementById("main"));
                    var colorData = ['#29AFD4', '#467897', '#D80835'];
                    option = {
                        tooltip: {
                            trigger: 'item',
                            formatter: "{a} <br/>{b}: {c} ({d}%)"
                        },
                        legend: {
                            orient: 'vertical',
                            x: 'left',
                            data:['好评','中评','差评']
                        },
                        series: [
                            {
                                name:'用户评论',
                                type:'pie',
                                radius: ['30%', '70%'],
                                color: colorData,
                                avoidLabelOverlap: false,
                                label: {
                                    normal: {
                                        show: false,
                                        position: 'center'
                                    },
                                    emphasis: {
                                        show: true,
                                        textStyle: {
                                            fontSize: '30',
                                            fontWeight: 'bold'
                                        }
                                    }
                                },
                                labelLine: {
                                    normal: {
                                        show: false
                                    }
                                },
                                data:[
                                    {value:result.data.great, name:'好评'},
                                    {value:result.data.mid, name:'中评'},
                                    {value:result.data.bad, name:'差评'}
                                ]
                            }
                        ]
                    };
                    // 使用刚指定的配置项和数据显示图表。
                    myChart.setOption(option);
                }
            }
        });

        var pageEvaluationParams = {
            "rating": $("#rating").val(),
            "userId": userId,
            "pageNum": $("#pageNum").val(),
            "pageSize": 5,
            "orderBy" : "time desc"
        }

        $.ajax({
            type: "POST",
            async: false,
            url: "evaluation/evaluation-server/pagePost",
            headers: { // token
                'Authorization' : userInfo.token
            },
            dataType: "json",        //返回数据形式为json
            contentType: 'application/json; charset=UTF-8',
            data: JSON.stringify(pageEvaluationParams),
            success: function (result) {
                if (result.status == 200) {
                    var list = result.data.list;
                    var str =
                        "<div class=\'detail_tab_list\'>" +
                        "<div class=\'detail_tab_con\'>" +
                        "<div class=\'item\'>";
                    for (var i = 0; i < list.length; i++) {
                        str +=
                            "<ul class=\'item_info\'>" +
                            "<div class=\'comment\'>" +
                            "<div class=\'comment_imgdiv\'>" +
                            "<img class=\'comment_imgcss\' src=\'"+list[i].postPhoto+"\'/>" +
                            "</div>" +
                            "<div class=\'conmment_details\'>" +
                            "<div style=\'float:left;\'>" +
                            "<span class=\'comment_name\'>"+list[i].postName+"</span>&ensp;&ensp;&ensp;&ensp;&ensp;<span>" + list[i].time + "</span>" +
                            "</div>" +
                            "<div class=\'del\'>" +
                            "</div>" +
                            "<div class=\'comment_content\'>"+list[i].context+"</div>" +
                            "<span style='vertical-align: middle' class='postName'>" + list[i].goodsTitle + "</span>" +
                            "<span style='vertical-align: middle;margin-top: 0px' class='postPhoto'><img class='img-profile rounded-circle' style" +
                            "='width: 30px;height: 30px' src='" + list[i].goodsPhoto + "'></span>" +
                            "</div>" +
                            "</div>" +
                            "</ul>";
                    }
                    document.getElementById('mod').innerHTML = str;
                }
            }
        });
    }

    function prePage() {
        if(document.getElementById('prePage').value == 0){
            alert("当前为第一页");
            return;
        }
        init(0);
        pageNum = document.getElementById('prePage').value;
        document.getElementById("prePageButton").click();
        comment();
    }
    function nextPage() {
        if(document.getElementById('nextPage').value == 0){
            alert("当前为最后一页");
            return;
        }
        init(0);
        pageNum = document.getElementById('nextPage').value;
        document.getElementById("nextPageButton").click();
        comment();
    }

    function comment() {

    }

    function description() {
        var str =
            "<div class=\'detail_tab_list\'>"  +
            "<ul>" +
            "<li class=\'current\'><a onclick= \'description()\'>商品介绍</a></li>" +
            "<li><a onclick= 'comment()'>商品评论</a></li>" +
            "</ul>" +
            "</div>" +
            "<div class=\'detail_tab_con\'>" +
            "<div class='item' style='margin-left: 100px'>" +
            goodsInfo.description +
            "<br><div style='margin-left: 100px'>" +
            "<img weight='500px' height='500px' src='"+ goodsInfo.photo +"'><br>";
            if(goodsInfo.photoA != null){
                str += "<img weight='500px' height='500px' src='"+ goodsInfo.photoA +"'><br>";
            }
            if(goodsInfo.photoB != null){
                str += "<img weight='500px' height='500px' src='"+ goodsInfo.photoB +"'><br>";
            }
            if(goodsInfo.photoC != null){
                str += "<img weight='500px' height='500px' src='"+ goodsInfo.photoC +"'><br>";
            }
            if(goodsInfo.photoD != null){
                str += "<img weight='500px' height='500px' src='"+ goodsInfo.photoD +"'><br>";
            }
            if(goodsInfo.photoE != null){
                str += "<img weight='500px' height='500px' src='"+ goodsInfo.photoE +"'><br>";
            }
            str += "</div></div></div>";
        document.getElementById('mod').innerHTML =str;
    }


</script>

</html>